package com.android.questions.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.android.base.util.DQLog;
import com.android.base.util.DateUtil;
import com.android.questions.config.AppConfig;

/**
 * FileName: TimeTickReceiver
 * Author: admin
 * Date: 2021/11/10 13:58
 * Description:
 */
public class TimeTickReceiver extends BroadcastReceiver {

    private int onlineTime = 0;

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(Intent.ACTION_TIME_TICK)) {
            onlineTime++;
            int dayOnlineTime = AppConfig.getDayOnLineTime() + 1;
            AppConfig.setDayOnLineTime(dayOnlineTime);
            String date = DateUtil.getDate(DateUtil.hm);
            DQLog.e("当前系统时间：" + date + ", 当前已在线时长:" + dayOnlineTime + "分钟, onlineTime -> " + onlineTime);

            if (date.equals("08:00")) {
                if (!AppConfig.getResetOnlineState()) {
                    AppConfig.setDayAnswerNumber(0);
                    AppConfig.setResetOnlineState(true);
                }
            }
        }
    }
}